<?php
/**
 * Created by PhpStorm.
 * User: 毛文科
 * Date: 2018\10\28 0028
 * Time: 10:03
 */
namespace app\admin\model;
use think\Db;
use think\exception\ErrorException;

class Databases
{
    /**添加表
     * @param array $array
     * @return bool
     */
    public static function add_table(array $array){
        $table = config('database.prefix').$array['surface'];
        $engine = $array['engine'];
        if(!$engine){
            $engine = 'innodb';
        }
        $type   = $array['model_type'];
        $sql = '';
        if($type=='普通模型'){
            $sql = "create table $table (uid int(255) auto_increment primary key";
        }elseif ($type=='单表模型'){
            $sql = "create table $table (id int(255) auto_increment primary key,model_id int(255),cid int(255),title varchar(255),status varchar(255),dir varchar(255),sort int(255),keywords varchar(255), description text(0),create_time int(255),update_time int(255)";
        }elseif ($type=='联表模型'){
            $sql = "create table $table (id int(255) auto_increment primary key,name varchar(255),pid int(255),sort int(255),tubiao varchar(255),create_time int(255)";
        }
        $sql = $sql.")engine=$engine";
//        return $sql;
        try{
          Db::execute($sql);
          return true;
        }catch (ErrorException $e){
            return false;
        }
    }

    /**修改表
     * @param array $array
     * @return bool
     */
    public static function update_table(array $array){
        $data = Db::name('model')->where('id',$array['id'])->find();
        $table = config('database.prefix').$data['surface'];
        $newtable = config('database.prefix').$array['surface'];
        $engine = $data['engine'];
        $newengine = $array['engine'];
        $sql = '';
        if($engine!==$newengine){
            $sql = "alter table $table engine=$newengine";
            try{
                Db::execute($sql);
                $bools = true;
            }catch (ErrorException $e){
                return false;
            }
        }
        if($table!==$newtable){
            $sql = "alter table $table rename $newtable";
            try{
                Db::execute($sql);
                $bool = true;
            }catch (ErrorException $e){
                return false;
            }
        }
        return true;
    }

    /**删除表
     * @param $table：表名称
     * @return bool：是否删除
     */
    public static function del_table($table){
        $table = config('database.prefix').$table;
        $sql = "drop table $table";
        try{
            Db::execute($sql);
            return true;
        }catch (ErrorException $e){
            return false;
        }
    }

    /**添加字段
     * @param $table：表名称
     * @param array $array：字段属性
     * @return bool
     */
    public static function add_feild($table,array $array){
        $name = $array['field_title'];
        $type = $array['types'];
        $lang = $array['lang'];
        $table = config('database.prefix').$table;
        $sql = "alter table $table add $name $type(".$lang.")";
        try{
            Db::execute($sql);
            return true;
        }catch (ErrorException $e){
            return false;
        }
    }

    /**删除字段
     * @param $table：表名称
     * @param $name：字段名称
     * @return bool
     */
    public static function dele_feild($table,$name){
        $table = config('database.prefix').$table;
        $sql = "alter table $table drop column $name";
//        return $sql;
        try{
            Db::execute($sql);
            return true;
        }catch (ErrorException $e){
            return false;
        }
    }

    /**修改字段
     * @param $table：表名称
     * @param $name：原名称
     * @param array $array：新属性
     * @return bool
     */
    public static function update_fieldattribute($table,$name,array $array){
        $table = config('database.prefix').$table;
        $type  = $array['types'];
        $lang  = $array['lang'];
        $newname = $array['name'];
        $sql = "alter table $table change $name $newname $type($lang)";
//        return $sql;
        try{
            Db::execute($sql);
            return true;
        }catch (ErrorException $e){
            return false;
        }
    }

    /**普通模型
     * @param $models:模型的id
     * @param $model：模型的名称
     * @param $pid：上级id
     * @return string
     */
    public static function get_add_p($models,$pid){
        if($pid){
            $lanmu = (new Commons())->getDatas($pid);
            $lanmu[]   = Db::name('document')->where('id',$pid)->find();
        }else{
            $lanmu = Db::view('document',true)
                ->view('model','surface','document.model=model.id','left')
                ->where('surface','navigation')
                ->whereOr('surface','cate')
                ->select();
        }
        if(!$pid){
            $lanmu[] = ['id'=>0,'title'=>'网站门户'];
        }
        $str = GetHtml::GetHtml_for_document($lanmu);
        $data = Db::name('table_field')->where('modelid',$models)->select();
        foreach ($data as $value) {
            //单行文本添加
            if ($value['field_type'] == '单行文本') {
                $str .= GetHtml::GetHtml_for_danhangwenben($value);
                //多行文本添加
            } elseif ($value['field_type'] == '多行文本') {
                $str .= GetHtml::GetHtml_for_duowenjian($value);
                //单文件
            } elseif ($value['field_type'] == '单图片') {
                $str .= GetHtml::GetHtml_for_dantupian($value);
                //多文件
            } elseif ($value['field_type'] == '多图片') {
                $str .= GetHtml::GetHtml_for_duotupian($value);
                //单选框
            } elseif ($value['field_type'] == '单文件') {
                $str .= GetHtml::GetHtml_for_danwenjian($value);
                //单选框
            } elseif ($value['field_type'] == '多文件') {
                $str .= GetHtml::GetHtml_for_duowenjian($value);
                //单选框
            } elseif ($value['field_type'] == '单选框') {
                $str .= GetHtml::GetHtml_for_danxuankuang($value);
                //复选框
            }elseif ($value['field_type'] == '复选框'){
                $str .= GetHtml::GetHtml_for_fuxuankuang($value);
                //下拉框
            }elseif ($value['field_type'] == '下拉框'){
                $str .= GetHtml::GetHtml_for_xialakuang($value);
                //编辑文本
            }elseif($value['field_type'] == '编辑文本'){
                $str .= GetHtml::GetHtml_for_bianjiwenben($value);
            }
        }
        return $str;
    }

    /**单表模型加载添加数据
     * @param $models：模型id
     * @param $model：模型名称
     * @param $pid：上级栏目id
     * @return string
     */
    public static function get_add_d($models,$model,$pid){
        if($pid){
            $lanmus = (new Commons())->getData($pid);
            $lanmu = [];
            $docu   = Db::name('document')->where('id',$pid)->find();
            $lanmus[] = $docu;
            $modeid = (Db::name('model')->where('surface','cate')->find())['id'];
            foreach ($lanmus as $value){
                if($value['model']==$modeid){
                    $lanmu[] = $value;
                }
            }
        }else{
            $lanmu = Db::view('document',true)
                ->view('model','surface','document.model=model.id','left')
                ->where('surface','cate')
                ->select();
        }
        $str = '';
        $data = Db::name('table_field')->where('modelid',$models)->select();
//        echo '<pre>';
//        print_r($data);exit;
        foreach ($data as $value) {
            //单行文本添加
            if ($value['field_type'] == '单行文本') {
//                echo '<pre>';
//                print_r($value);exit;
                if ($value['type_status'] == 1) {
//                    return 12;exit;
                    $str .= '<div class="row cl">
		<label class="form-label col-xs-4 col-sm-3">
			<span class="c-red">*</span>' . $value['field_name'] . '：
		</label>
		<div class="formControls col-xs-8 col-sm-9">
			<input type="text" class="input-text" id="' . $value['field_title'] . '" name="' . $value['field_title'] . '" >
		</div>
	</div>';
                }
                //多行文本添加
            } elseif ($value['field_type'] == '多行文本') {
                if ($value['type_status'] == 1) {
                    $str .= '<div class="row cl">
			<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>' . $value['field_name'] . '：</label>
			<div class="formControls col-xs-8 col-sm-9">
				<textarea name="' . $value['field_title'] . '" id="' . $value['field_title'] . '" style="width: 100%;height: 100px"></textarea>
			</div>
		</div>';
                }
                //单文件
            } elseif ($value['field_type'] == '单文件') {
                if ($value['type_status'] == 1) {
                    $str .= '<div class="row cl">
			<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>' . $value['field_name'] . '：</label>
			<div class="formControls col-xs-8 col-sm-9">
				<div class="file">
					<input type="file" id="' . $value['field_title'] . '" name="' . $value['field_title'] . '" onchange="yulan(this)">点击预览
				</div>
			</div>
		</div>
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>图片预览：</label>
			<div class="formControls col-xs-8 col-sm-9 show">
				
			</div>
		</div>';
                }
                //多文件
            } elseif ($value['field_type'] == '多文件') {
                if ($value['type_status'] == 1) {
                    $str .= '<div class="row cl">
			<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>' . $value['field_name'] . '：</label>
			<div class="formControls col-xs-8 col-sm-9">
				<div class="file">
					<input type="file" id="' . $value['field_title'] . '" name="' . $value['field_title'] . '[]" onchange="yulan(this)" multiple>点击预览
				</div>
			</div>
		</div>
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>图片预览：</label>
			<div class="formControls col-xs-8 col-sm-9 show">
				
			</div>
		</div>';
                }
                //单选框
            } elseif ($value['field_type'] == '单选框') {
                if ($value['type_status'] == 1) {
                    $str .= '<div class="row cl">
			<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>'.$value['field_name'].'：</label>
			<div class="formControls col-xs-8 col-sm-9">';
                    if ($value['type_option']) {
                        $array = explode(',', $value['type_option']);
                        foreach ($array as $values) {
                            $str .= '<input type="radio" name="'.$value['field_title'].'" value="'.$values . '">'.$values;
                        }
                    }

                    $str .= '</div>
		</div>';
                }
                //复选框
            }elseif ($value['field_type'] == '复选框'){
                if ($value['type_status'] == 1) {
                    $str .='<div class="row cl">
			<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>'.$value['field_name'].'：</label>
			<div class="formControls col-xs-8 col-sm-9">';
                    if ($value['type_option']) {
                        $array = explode(',', $value['type_option']);
                        foreach ($array as $values) {
                            $str .= '<input type="checkbox" name="'.$value['field_title'].'[]" value="' . $values . '">' . $values;
                        }
                    }

                    $str .= '</div>
		</div>';
                }
                //下拉框
            }elseif ($value['field_type'] == '下拉框'){
                if ($value['type_status'] == 1) {
                    $str .='<div class="row cl">
			<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>'.$value['field_name'].'：</label>
			<div class="formControls col-xs-8 col-sm-9"><select name="'.$value['field_title'].'">';
                    if ($value['type_option']) {
                        $array = explode(',', $value['type_option']);
                        foreach ($array as $values) {
                            $str .= '<option value="'.$values.'">'.$values.'</option>';
                        }
                    }

                    $str .= '</select></div>
		</div>';
                }
                //编辑文本
            }elseif($value['field_type'] == '编辑文本'){
                if ($value['type_status'] == 1) {
                    $str .='<div class="row cl">
		<label class="form-label col-xs-4 col-sm-3">
			<span class="c-red">*</span>' . $value['field_name'] . '：
		</label>
		<div class="formControls col-xs-8 col-sm-9">
			<script id="editor" type="text/plain" name="'.$value['field_title'].'" style="width:100%;height:500px;"></script>
		</div>
	</div>';
                }
            }
//            return $str;
        }
        return $str;
    }

    /**添加普通模型的数据
     * @param array $model：模型的数据
     * @param $data：提交的数据
     * @param $file：上传的文件
     * @return array|bool|int
     */
    public static function add_data_p(array $model,$data,$file){
       
        //讲document表数据单独取出
        $document['title'] = $data['title'];
        $document['pid'] = $data['pid'];
        $document['status'] = $data['status'];
        $document['dir'] = $data['dir'];
        $document['sort'] = $data['sort'];
        $document['model'] = $data['model'];
        $document['keywords'] = $data['keywords'];
        $document['description'] = $data['description'];
        //删除$data的多余数据
        unset($data['title']);
        unset($data['pid']);
        unset($data['status']);
        unset($data['dir']);
        unset($data['sort']);
        unset($data['model']);
        unset($data['keywords']);
        unset($data['description']);
        $uid = Db::name('document')->insertGetId($document);
        $array = Db::name('table_field')->where('modelid',$model['id'])->select();
        foreach ($array as $value){
            if($value['field_type']=='单行文本'){
                $data[$value['field_title']] = $data[$value['field_title']];
            }elseif ($value['field_type']=='多行文本'){
                $data[$value['field_title']] = $data[$value['field_title']];
            }elseif ($value['field_type']=='单文件'){
                if(isset($file[$value['field_title']])){
                    $img = Qinu::Upfile($file[$value['field_title']]);
                    if($img){
                        $data[$value['field_title']] = $img;
                    }
                }
            }elseif($value['field_type']=='多文件'){
                if(isset($file[$value['field_title']])){
                    $img = Qinu::Upfile($file[$value['field_title']]);
                    if($img){
                        $data[$value['field_title']] = json_encode($img);
                    }
                }
            }elseif ($value['field_type']=='单图片'){
                if(isset($file[$value['field_title']])){
                    $img = Qinu::Upfile($file[$value['field_title']]);
                    if($img){
                        $data[$value['field_title']] = $img;
                    }
                }
            }elseif ($value['field_type']=='视频'){
                if(isset($file[$value['field_title']])){
                    $img = Qinu::Upfile($file[$value['field_title']]);
                    if($img){
                        $data[$value['field_title']] = $img;
                    }
                }
            }elseif($value['field_type']=='多图片'){
                if(isset($file[$value['field_title']])){
                    $img = Qinu::Upfile($file[$value['field_title']]);
                    if($img){
                        $data[$value['field_title']] = json_encode($img);
                    }
                }
            }elseif($value['field_type']=='单选框'){
                if(isset($data[$value['field_title']])){
                    $data[$value['field_title']] = $data[$value['field_title']];
                }
            }elseif ($value['field_type']=='复选框'){
                if(isset($data[$value['field_title']])){
                    $data[$value['field_title']] = json_encode($data[$value['field_title']]);
                }
            }elseif ($value['field_type']=='下拉框'){
                $data[$value['field_title']] = $data[$value['field_title']];
            }elseif ($value['field_type']=='编辑文本'){
                if(isset($data[$value['field_title']])){
                    $data[$value['field_title']] = $data[$value['field_title']];
                }
            }
        }
        $data['uid'] = $uid;
        if(Db::name($model['surface'])->insert($data)){
            return true;
        }else{
            return false;
        }
    }
    /**加载编辑页面，普通表模型
     * @param $id：document的id
     * @param $pid：上级的id
     * @return string
     */
    public static function get_edit($id,$pid){
        $resul = Db::connect();
        $data = $resul->view('document',true)
            ->view('model','surface','document.model=model.id','left')
            ->where('document.id',$id)
            ->find();
        $arrays = $resul->name('table_field')->where('modelid',$data['model'])->select();
        if($pid){
            $lanmu = (new Commons())->getDatas($pid);
            $lanmu[]   = Db::name('document')->where('id',$pid)->find();
        }else{
            $lanmu = Db::view('document',true)
                ->view('model','surface','document.model=model.id','left')
                ->where('surface','navigation')
                ->whereOr('surface','cate')
                ->select();
        }
        if(!$pid){
            $lanmu[] = ['id'=>0,'title'=>'网站门户'];
        }
        $str = GetHtml::GetHtml_for_document($lanmu,$data);
        $shuju = $resul->name($data['surface'])->where('uid',$id)->find();
        foreach ($arrays as $value){
            if ($value['field_type'] == '单行文本') {
                $str .= GetHtml::GetHtml_for_danhangwenben($value,$shuju);
                //多行文本添加
            } elseif ($value['field_type'] == '多行文本') {
                $str .= GetHtml::GetHtml_for_duowenjian($value,$shuju);
                //单文件
            } elseif ($value['field_type'] == '单图片') {
                $str .= GetHtml::GetHtml_for_dantupian($value,$shuju);
                //多文件
            } elseif ($value['field_type'] == '多图片') {
                $str .= GetHtml::GetHtml_for_duotupian($value,$shuju);
                //单选框
            }elseif ($value['field_type'] == '单文件') {
                $str .= GetHtml::GetHtml_for_danwenjian($value,$shuju);
                //单选框
            }elseif ($value['field_type'] == '多文件') {
                $str .= GetHtml::GetHtml_for_duowenjian($value,$shuju);
                //单选框
            } elseif ($value['field_type'] == '单选框') {
                $str .= GetHtml::GetHtml_for_danxuankuang($value,$shuju);
                //复选框
            }elseif ($value['field_type'] == '复选框'){
                $str .= GetHtml::GetHtml_for_fuxuankuang($value,$shuju);
                //下拉框
            }elseif ($value['field_type'] == '下拉框'){
                $str .= GetHtml::GetHtml_for_xialakuang($value,$shuju);
                //编辑文本
            }elseif($value['field_type'] == '编辑文本'){
                $str .= GetHtml::GetHtml_for_bianjiwenben($value,$shuju);
            }
        }
        return $str;
    }

    /**更新数据
     * @param $data：数据
     * @param $file：文件
     * @return bool：返回保存成功或失败
     */
    public static function update_p($data,$file){
        $uid = $data['uid'];
        $document['title'] = $data['title'];
        unset($data['title']);
        $document['pid'] = $data['pid'];
        unset($data['pid']);
        $document['status'] = $data['status'];
        unset($data['status']);
        $document['dir'] = $data['dir'];
        unset($data['dir']);
        $document['sort'] = $data['sort'];
        unset($data['sort']);
        $document['keywords'] = $data['keywords'];
        unset($data['keywords']);
        $document['description'] = $data['description'];
        unset($data['description']);
        $documents = Db::name('document')->where('id',$uid)->find();
        $table    = Db::name('model')->where('id',$documents['model'])->find();
        $shuju    = Db::name($table['surface'])->where('uid',$uid)->find();
        $array = Db::name('table_field')->where('modelid',$documents['model'])->select();
        foreach ($array as $value){
            if($value['field_type']=='单行文本'){
                $data[$value['field_title']] = $data[$value['field_title']];
            }elseif ($value['field_type']=='多行文本'){
                $data[$value['field_title']] = $data[$value['field_title']];
            }elseif ($value['field_type']=='单文件'){
                if(isset($file[$value['field_title']])){
                    $img = Qinu::Upfile($file[$value['field_title']]);
                    if($img){
                        if($shuju[$value['field_title']]){
                            Qinu::DeleFile($shuju[$value['field_title']]);
                        }
                        $data[$value['field_title']] = $img;
                    }
                }
            }elseif ($value['field_type']=='单图片'){
                if(isset($file[$value['field_title']])){
                    $img = Qinu::Upfile($file[$value['field_title']]);
                    if($img){
                        if($shuju[$value['field_title']]){
                            Qinu::DeleFile($shuju[$value['field_title']]);
                        }
                        $data[$value['field_title']] = $img;
                    }
                }
            }elseif ($value['field_type']=='视频'){
                if(isset($file[$value['field_title']])) {
                    $img = Qinu::Upfile($file[$value['field_title']]);
                    if ($img) {
                        if ($shuju[$value['field_title']]) {
                            Qinu::DeleFile($shuju[$value['field_title']]);
                        }
                        $data[$value['field_title']] = $img;
                    }
                }
            }elseif($value['field_type']=='多文件'){
                if(isset($file[$value['field_title']])) {
                    $img = Qinu::Upfile($file[$value['field_title']]);
                    if ($img) {
                        if ($shuju[$value['field_title']] && count(json_decode($shuju[$value['field_title']], true))) {
                            $j = json_decode($shuju[$value['field_title']], true);
                            foreach ($j as $v) {
                                Qinu::DeleFile($v);
                            }
                        }
                        $data[$value['field_title']] = json_encode($img);
                    }
                }
            }elseif($value['field_type']=='多图片'){
                if(isset($file[$value['field_title']])) {
                    $img = Qinu::Upfile($file[$value['field_title']]);
                    if ($img) {
                        if ($shuju[$value['field_title']] && count(json_decode($shuju[$value['field_title']], true))) {
                            $j = json_decode($shuju[$value['field_title']], true);
                            foreach ($j as $v) {
                                Qinu::DeleFile($v);
                            }
                        }
                        $data[$value['field_title']] = json_encode($img);
                    }
                }
            }elseif($value['field_type']=='单选框'){
                if(isset($data[$value['field_title']])){
                    $data[$value['field_title']] = $data[$value['field_title']];
                }
            }elseif ($value['field_type']=='复选框'){
                if(isset($data[$value['field_title']])){
                    $data[$value['field_title']] = json_encode($data[$value['field_title']]);
                }
            }elseif ($value['field_type']=='下拉框'){
                $data[$value['field_title']] = $data[$value['field_title']];
            }elseif ($value['field_type']=='编辑文本'){
                if(isset($data[$value['field_title']])){
                    $data[$value['field_title']] = $data[$value['field_title']];
                }
            }
        }
//        echo '<pre>';
//        print_r($data);exit;
       if(Db::name('document')->where('id',$uid)->update($document)||Db::name($table['surface'])->where('uid',$uid)->update($data)){
            return true;
       }else{
           return false;
       }
    }

    /**普通模型查看详情
     * @param $id
     * @return string
     */
    public static function getinfo_p($id){
        $data = Db::view('document',true)
            ->view('model','surface','model.id=document.model')
            ->where('document.id',$id)
            ->find();
        $str = '<div class="row cl">
			<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>文档名称：</label>
			<div class="formControls col-xs-8 col-sm-9">'
				.$data['title'].
			'</div>
		</div><div class="row cl">
			<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>上级栏目：</label>
			<div class="formControls col-xs-8 col-sm-9">';
				if($data['pid']==0){
				    $str.= '最上级';
                }else{
				    $str .= (Db::name('document')->where('id',$data['pid'])->find())['title'];
                }
			$str.='</div>
		</div>
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>状态：</label>
			<div class="formControls col-xs-8 col-sm-9">';
        if($data['status']=='1'){
            $str .= '启用';
        }else{
            $str .= '禁用';
        }
        $str .='</div>
		</div>
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>地址描述：</label>
			<div class="formControls col-xs-8 col-sm-9">'.$data['dir'].'</div>
		</div>
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>排序：</label>
			<div class="formControls col-xs-8 col-sm-9">'.$data['sort'].'</div>
		</div>
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>关键词：</label>
			<div class="formControls col-xs-8 col-sm-9">'.$data['keywords'].'</div>
		</div>
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>关键词描述：</label>
			<div class="formControls col-xs-8 col-sm-9">'.$data['description'].'</div>
		</div>';
        $arrays = Db::name($data['surface'])->where('uid',$id)->find();
        $array  = Db::name('table_field')->where('modelid',$data['model'])->select();
//        echo '<pre>';
//        print_r($array);exit;
        foreach ($array as $value){
            if($value['field_type']=='单行文本'){
                $str .= '<div class="row cl">
			<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>'.$value['field_name'].'：</label>
			<div class="formControls col-xs-8 col-sm-9">'.$arrays[$value['field_title']].'</div>
		</div>';
            }elseif ($value['field_type']=='多行文本'){
                $str .= '<div class="row cl">
			<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>'.$value['field_name'].'：</label>
			<div class="formControls col-xs-8 col-sm-9">'.$arrays[$value['field_title']].'</div>
		</div>';
            }elseif ($value['field_type']=='单文件'){
                $str .= '<div class="row cl">
			<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>'.$value['field_name'].'：</label>
			<div class="formControls col-xs-8 col-sm-9">';
                if($arrays[$value['field_title']]){
                    $str .= get_img($arrays[$value['field_title']]);
                }
                $str.='</div>
		</div>';
            }elseif ($value['field_type']=='单图片'){
                $str .= '<div class="row cl">
			<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>'.$value['field_name'].'：</label>
			<div class="formControls col-xs-8 col-sm-9">';
                if($arrays[$value['field_title']]){
                    $str .= '<img src="'.get_img($arrays[$value['field_title']]).'" width="150"/>';
                }
                $str.='</div>
		</div>';
            }elseif ($value['field_type']=='视频'){
                $str .= '<div class="row cl">
			<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>'.$value['field_name'].'：</label>
			<div class="formControls col-xs-8 col-sm-9">';
                if($arrays[$value['field_title']]){
                    $str .= '<video src="'.config('fuwuqi').'/'.$arrays[$value['field_title']].'" controls="controls" style="width: 50%">
您的浏览器不支持 video 标签。
                    </video>';
                }
                $str.='</div>
		</div>';
            }elseif ($value['field_type']=='多文件'){
                $str .= '<div class="row cl">
			<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>'.$value['field_name'].'：</label>
			<div class="formControls col-xs-8 col-sm-9">';
                if($arrays[$value['field_title']]&&count(json_decode($arrays[$value['field_title']],true))){
                    $ar = json_decode($arrays[$value['field_title']],true);
                    foreach ($ar as $val){
                        $str .= ''.get_img($val).';';
                    }
                }
                $str.='</div>
		</div>';
            }elseif ($value['field_type']=='多图片'){
                $str .= '<div class="row cl">
			<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>'.$value['field_name'].'：</label>
			<div class="formControls col-xs-8 col-sm-9">';
                if($arrays[$value['field_title']]&&count(json_decode($arrays[$value['field_title']],true))){
                    $ar = json_decode($arrays[$value['field_title']],true);
                    foreach ($ar as $val){
                        $str .= '<img src="'.get_img($val).'" width="150"/>';
                    }
                }
                $str.='</div>
		</div>';
            }elseif ($value['field_type']=='单选框'){
                $str .= '<div class="row cl">
			<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>'.$value['field_name'].'：</label>
			<div class="formControls col-xs-8 col-sm-9">'.$arrays[$value['field_title']].'</div>
		</div>';
            }elseif ($value['field_type']=='复选框'){
                $str .= '<div class="row cl">
			<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>'.$value['field_name'].'：</label>
			<div class="formControls col-xs-8 col-sm-9">';
                if($arrays[$value['field_title']]&&count(json_decode($arrays[$value['field_title']],true))){
                    $arrr = json_decode($arrays[$value['field_title']],true);
                    foreach ($arrr as $ul){
                        $str .= $ul.'，';
                    }
                }
                $str.='</div>
		</div>';
            }elseif ($value['field_type']=='下拉框'){
                $str .= '<div class="row cl">
			<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>'.$value['field_name'].'：</label>
			<div class="formControls col-xs-8 col-sm-9">'.$arrays[$value['field_title']].'</div>
		</div>';
            }elseif ($value['field_type']=='编辑文本'){
                $str .= '<div class="row cl">
			<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>'.$value['field_name'].'：</label>
			<div class="formControls col-xs-8 col-sm-9">'.$arrays[$value['field_title']].'</div>
		</div>';
            }
        }
        return $str;
    }
}